Stepper 28 Click
Stepper 28 Click demo application is developed using the NECTO Studio, ensuring compatibility with mikroSDK's open-source libraries and tools. Designed for plug-and-play implementation and testing, the demo is fully compatible with all development, starter, and mikromedia boards featuring a mikroBUS™ socket.
Click Library
- Author : Stefan Filipovic
- Date : Jul 2025.
- Type : I2C type
Software Support
Example Description
This example demonstrates the use of the Stepper 28 Click board by driving the motor in both directions for a desired number of steps.
Example Libraries
- MikroSDK.Board
- MikroSDK.Log
- Click.Stepper28
Example Key Functions
- stepper28_cfg_setup This function initializes Click configuration structure to initial values.
void stepper28_cfg_setup(stepper28_cfg_t *cfg)
Stepper 28 configuration object setup function.
Stepper 28 Click configuration object.
Definition stepper28.h:243
- stepper28_init This function initializes all necessary pins and peripherals used for this Click board.
err_t stepper28_init(stepper28_t *ctx, stepper28_cfg_t *cfg)
Stepper 28 initialization function.
Stepper 28 Click context object.
Definition stepper28.h:221
- stepper28_default_cfg This function executes a default configuration of Stepper 28 Click board.
err_t stepper28_default_cfg(stepper28_t *ctx)
Stepper 28 default configuration function.
- stepper28_set_direction This function sets the motor direction by setting the DIR pin logic state.
void stepper28_set_direction(stepper28_t *ctx, uint8_t dir)
Stepper 28 set direction function.
- stepper28_set_step_mode This function sets the step mode resolution settings.
err_t stepper28_set_step_mode(stepper28_t *ctx, uint8_t mode)
Stepper 28 set step mode function.
- stepper28_drive_motor This function drives the motor for the specific number of steps at the selected speed.
void stepper28_drive_motor(stepper28_t *ctx, uint32_t steps, uint8_t speed)
Stepper 28 driver motor function.
Application Init
Initializes the driver and performs the Click default configuration.
{
log_cfg_t log_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
if ( I2C_MASTER_ERROR ==
stepper28_init( &stepper28, &stepper28_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
{
log_error( &logger, " Default configuration." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
}
#define STEPPER28_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition stepper28.h:205
void application_init(void)
Definition main.c:30
@ STEPPER28_ERROR
Definition stepper28.h:264
Application Task
Drives the motor clockwise for 200 full steps and then counter-clockwise for 200 half steps and 400 quarter steps with a 1 second delay on driving mode change. All data is being logged on the USB UART where you can track the program flow.
{
log_printf ( &logger, " Move 200 full steps clockwise, speed: slow\r\n\n" );
Delay_ms ( 1000 );
log_printf ( &logger, " Move 200 half steps counter-clockwise, speed: medium\r\n\n" );
Delay_ms ( 1000 );
log_printf ( &logger, " Move 400 quarter steps counter-clockwise, speed: fast\r\n\n" );
Delay_ms ( 1000 );
}
#define STEPPER28_DIR_CW
Stepper 28 direction setting.
Definition stepper28.h:122
#define STEPPER28_SPEED_FAST
Definition stepper28.h:172
#define STEPPER28_DIR_CCW
Definition stepper28.h:123
#define STEPPER28_SPEED_MEDIUM
Definition stepper28.h:171
#define STEPPER28_MODE_QUARTER_STEP
Definition stepper28.h:142
#define STEPPER28_MODE_FULL_STEP
Stepper 28 step resolution setting.
Definition stepper28.h:136
#define STEPPER28_MODE_HALF_STEP_TYPE_A
Definition stepper28.h:140
#define STEPPER28_SPEED_SLOW
Definition stepper28.h:170
void application_task(void)
Definition main.c:66
Application Output
This Click board can be interfaced and monitored in two ways:
- Application Output - Use the "Application Output" window in Debug mode for real-time data monitoring. Set it up properly by following this tutorial.
- UART Terminal - Monitor data via the UART Terminal using a USB to UART converter. For detailed instructions, check out this tutorial.
Additional Notes and Information
The complete application code and a ready-to-use project are available through the NECTO Studio Package Manager for direct installation in the NECTO Studio. The application code can also be found on the MIKROE GitHub account.